<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\admin\model\App as AppModel;
use think\Db;
use think\exception\ValidateException;
use think\exception\PDOException;
use Exception;
use app\common\model\ScoreLog;


/**
 * @基础数据接口
 */
class App extends Api
{    
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['list', 'info'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];
    

    /**
     * @应用列表
     */
    public function list(AppModel $D, $type = null)
    {   
        $map['switch'] = 1;
        if ($type) {
            $map['type'] = $type;
        }
        $list = $D->where($map)->order('weigh DESC')->select();
        
        $this->success('应用列表', $list);
    }
    
    
    /**
     * @应用详情
     */
    public function info(AppModel $D, $id = null) {
        if (!$id) {
            $this->error('应用id不能为空');
        };
        if ($info = $D->get($id)) {
            $this->success('应用详情', $info);
        } else {
            $this->error('应用不存在');
        }
    }
    
    
    
}
